/*
 * Copyright 2002-2005 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package lib.jsonrpc;

// TODO: Auto-generated Javadoc
/**
 * The Class RPCException is thrown when exception happend.
 * 
 * 
 * @author jay liu
 * @since 02.10.2010
 */
public class RPCException extends RuntimeException{

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 5809514997402019478L;

	/** The error code. */
	private long errorCode = 0;
	
	
	/** The data. */
	private String data;
	
	/** The Constant COLLECTION_ERROR. */
	public final static long INVALID_REQUEST = -32600;
	
	/** The Constant JSON_FORMAT_ERROR. */
	public final static long PARSE_ERROR = -32700;
	
	/** The Constant NETWORK. */
	public final static long METHOD_NOT_FOUND = -32601;
	
	/** The Constant NOT_FOUND. */
	public final static long INVALID_PARAMETERS = -32602;
	
	/** The Constant INTERNAL_ERROR. */
	public final static long INTERNAL_ERROR = -32603;
	

	
	
	/**
	 * Instantiates a new rPC exception.
	 *
	 * @param errorCode the error code
	 */
	public RPCException(long errorCode){
		this.errorCode = errorCode;
	}
	
	/**
	 * Instantiates a new rPC exception.
	 *
	 * @param errorCode the error code
	 * @param message the message
	 */
	public RPCException(long errorCode, String message){
		super(message);
		this.errorCode = errorCode;
		
	}
	
	/**
	 * Instantiates a new rPC exception.
	 *
	 * @param errorCode the error code
	 * @param message the message
	 * @param cause the cause
	 */
	public RPCException(long errorCode, String message, Throwable cause){
		super(message, cause);
		this.errorCode = errorCode;
		
	}
	
	
	
	/**
	 * Gets the error code.
	 *
	 * @return the error code
	 */
	public long getErrorCode(){
		return errorCode;
	}

	
	/**
	 * Sets the data.
	 *
	 * @param data the new data
	 */
	public void setData(String data){
		this.data = data;
	}
	
	/**
	 * Gets the data.
	 *
	 * @return the data
	 */
	public String getData(){
		return data;
	}
	
}
